import rtoml
import json


def main():
    src_path = r'D:\Downloads\invalid.json'
    dst_toml_path = './output/invalid.toml'

    with open(src_path, 'r', encoding='utf-8') as f:
        src_books = json.load(f)

    toml_dict = {}
    for book in src_books:
        book_name = book['bookSourceName']
        whole_url = book['bookSourceUrl']
        toml_dict[whole_url] = book_name

    toml_text = rtoml.dumps(toml_dict)
    with open(dst_toml_path, 'w', encoding='utf-8') as f:
        f.write(toml_text)


if __name__ == '__main__':
    main()
